using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_portal_articles
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                usp_portal_articles_select_all entity = new usp_portal_articles_select_all();
                entity.STATUS = status;
                return BO_Actions<usp_portal_articles_select_all>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                usp_portal_articles_select_top entity = new usp_portal_articles_select_top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return BO_Actions<usp_portal_articles_select_top>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int article_id)
        {
            try
            {
                usp_portal_articles_search entity = new usp_portal_articles_search();
                entity.ARTICLE_ID = article_id;

                return BO_Actions<usp_portal_articles_search>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                usp_portal_articles_select_paged entity = new usp_portal_articles_select_paged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return BO_Actions<usp_portal_articles_select_paged>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(int category_id, int article_type, string article_code, string mutil_thumb_img, string thumb_img, string short_article_title, string short_article_title_eng, string full_article_title, string full_article_title_eng, string short_article_description, string short_article_description_eng, string full_article_description, string full_article_description_eng, string article_detail, string article_detail_eng, string meta_keyword, string meta_description, string tags, int total_download, int total_vote, int total_comment, int total_view, bool is_display_on_home_page, bool is_hot, int order_display, int order_display_in_category, DateTime published_date, DateTime approved_date, string approved_by, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                usp_portal_articles_insert entity = new usp_portal_articles_insert();
                entity.CATEGORY_ID = category_id;
                entity.ARTICLE_TYPE = article_type;
                entity.ARTICLE_CODE = article_code;
                entity.MUTIL_THUMB_IMG = mutil_thumb_img;
                entity.THUMB_IMG = thumb_img;
                entity.SHORT_ARTICLE_TITLE = short_article_title;
                entity.SHORT_ARTICLE_TITLE_ENG = short_article_title_eng;
                entity.FULL_ARTICLE_TITLE = full_article_title;
                entity.FULL_ARTICLE_TITLE_ENG = full_article_title_eng;
                entity.SHORT_ARTICLE_DESCRIPTION = short_article_description;
                entity.SHORT_ARTICLE_DESCRIPTION_ENG = short_article_description_eng;
                entity.FULL_ARTICLE_DESCRIPTION = full_article_description;
                entity.FULL_ARTICLE_DESCRIPTION_ENG = full_article_description_eng;
                entity.ARTICLE_DETAIL = article_detail;
                entity.ARTICLE_DETAIL_ENG = article_detail_eng;
                entity.META_KEYWORD = meta_keyword;
                entity.META_DESCRIPTION = meta_description;
                entity.TAGS = tags;
                entity.TOTAL_DOWNLOAD = total_download;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_COMMENT = total_comment;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.IS_HOT = is_hot;
                entity.ORDER_DISPLAY = order_display;
                entity.ORDER_DISPLAY_IN_CATEGORY = order_display_in_category;
                entity.PUBLISHED_DATE = published_date;
                entity.APPROVED_DATE = approved_date;
                entity.APPROVED_BY = approved_by;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_portal_articles_insert>.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 article_id, int category_id, int article_type, string article_code, string mutil_thumb_img, string thumb_img, string short_article_title, string short_article_title_eng, string full_article_title, string full_article_title_eng, string short_article_description, string short_article_description_eng, string full_article_description, string full_article_description_eng, string article_detail, string article_detail_eng, string meta_keyword, string meta_description, string tags, int total_download, int total_vote, int total_comment, int total_view, bool is_display_on_home_page, bool is_hot, int order_display, int order_display_in_category, DateTime published_date, DateTime approved_date, string approved_by, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                usp_portal_articles_update entity = new usp_portal_articles_update();
                entity.ARTICLE_ID = article_id;
                entity.CATEGORY_ID = category_id;
                entity.ARTICLE_TYPE = article_type;
                entity.ARTICLE_CODE = article_code;
                entity.MUTIL_THUMB_IMG = mutil_thumb_img;
                entity.THUMB_IMG = thumb_img;
                entity.SHORT_ARTICLE_TITLE = short_article_title;
                entity.SHORT_ARTICLE_TITLE_ENG = short_article_title_eng;
                entity.FULL_ARTICLE_TITLE = full_article_title;
                entity.FULL_ARTICLE_TITLE_ENG = full_article_title_eng;
                entity.SHORT_ARTICLE_DESCRIPTION = short_article_description;
                entity.SHORT_ARTICLE_DESCRIPTION_ENG = short_article_description_eng;
                entity.FULL_ARTICLE_DESCRIPTION = full_article_description;
                entity.FULL_ARTICLE_DESCRIPTION_ENG = full_article_description_eng;
                entity.ARTICLE_DETAIL = article_detail;
                entity.ARTICLE_DETAIL_ENG = article_detail_eng;
                entity.META_KEYWORD = meta_keyword;
                entity.META_DESCRIPTION = meta_description;
                entity.TAGS = tags;
                entity.TOTAL_DOWNLOAD = total_download;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_COMMENT = total_comment;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.IS_HOT = is_hot;
                entity.ORDER_DISPLAY = order_display;
                entity.ORDER_DISPLAY_IN_CATEGORY = order_display_in_category;
                entity.PUBLISHED_DATE = published_date;
                entity.APPROVED_DATE = approved_date;
                entity.APPROVED_BY = approved_by;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;

                return BO_Actions<usp_portal_articles_update>.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(string ids, string spliter, int delete_type)
        {
            try
            {
                usp_portal_articles_delete entity = new usp_portal_articles_delete();
                entity.IDS = ids;
                entity.SPLITER = spliter;
                entity.DELETE_TYPE = delete_type;

                return BO_Actions<usp_portal_articles_delete>.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int article_id)
        {
            try
            {
                usp_portal_articles_restore entity = new usp_portal_articles_restore();
                entity.ARTICLE_ID = article_id;

                return BO_Actions<usp_portal_articles_restore>.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAdmin(int category_id, string keyword, int startIndex, int pageCount, int status, string content_key)
        {
            try
            {
                usp_portal_articles_select_admin entity = new usp_portal_articles_select_admin();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                entity.KEYWORDS = keyword;
                entity.CONTENT_KEY = content_key;
                return BO_Actions<usp_portal_articles_select_admin>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchCategory(int category_id)
        {
            try
            {
                usp_portal_articles_search_category entity = new usp_portal_articles_search_category();
                entity.CATEGORY_ID = category_id;
                return BO_Actions<usp_portal_articles_search_category>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByCategory(int startIndex, int pageCount, int category_id, string content_key)
        {
            try
            {
                usp_portal_articles_select_by_category entity = new usp_portal_articles_select_by_category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.CATEGORY_ID = category_id;
                entity.CONTENT_KEY = content_key;
                return BO_Actions<usp_portal_articles_select_by_category>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
      
        public static DataTable SelectMore(int pageCount, int article_id, string content_key)
        {
            try
            {
                usp_portal_articles_select_more entity = new usp_portal_articles_select_more();
                entity.MAXRECORDS = pageCount;
                entity.ARTICLE_ID = article_id;
                entity.CONTENT_KEY = content_key;
                return BO_Actions<usp_portal_articles_select_more>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByModule(int id, int maxrecords)
        {
            try
            {
                usp_portal_articles_select_by_module_id entity = new usp_portal_articles_select_by_module_id();
                entity.ID = id;
                entity.MAXRECORDS = maxrecords;
                return BO_Actions<usp_portal_articles_select_by_module_id>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectLangByModule(int id, int maxrecords, int lang)
        {
            try
            {
                usp_portal_articles_lang_select_by_module_id entity = new usp_portal_articles_lang_select_by_module_id();
                entity.ID = id;
                entity.MAXRECORDS = maxrecords;
                entity.LANG = lang;
                return BO_Actions<usp_portal_articles_lang_select_by_module_id>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectLangByCategory(int startIndex, int pageCount, int category_id, string content_key, bool lang)
        {
            try
            {
                usp_portal_articles_select_lang_by_category entity = new usp_portal_articles_select_lang_by_category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.CATEGORY_ID = category_id;
                entity.CONTENT_KEY = content_key;
                entity.LANG = lang;
                return BO_Actions<usp_portal_articles_select_lang_by_category>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectLangMostviewByCategory(int startIndex, int pageCount, int category_id, string content_key, bool lang)
        {
            try
            {
                usp_portal_articles_select_lang_mostview_by_category entity = new usp_portal_articles_select_lang_mostview_by_category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.CATEGORY_ID = category_id;
                entity.CONTENT_KEY = content_key;
                entity.LANG = lang;
                return BO_Actions<usp_portal_articles_select_lang_mostview_by_category>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAdminDate(int category_id, string keyword, int startIndex, int pageCount, int status, string content_key, DateTime created_date)
        {
            try
            {
                usp_portal_articles_select_admin_date entity = new usp_portal_articles_select_admin_date();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                entity.KEYWORDS = keyword;
                entity.CONTENT_KEY = content_key;
                entity.CREATED_DATE = created_date;
                return BO_Actions<usp_portal_articles_select_admin_date>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectLangByModule(int id, int startindex, int maxrecords, int lang)
        {
            try
            {
                usp_portal_articles_select_lang_by_module_id entity = new usp_portal_articles_select_lang_by_module_id();
                entity.ID = id;
                entity.MAXRECORDS = maxrecords;
                entity.LANG = lang;
                entity.STARTINDEX = startindex;
                return BO_Actions<usp_portal_articles_select_lang_by_module_id>.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //select question
        public static DataTable SelectQuestion(int status) {
            try {
                usp_portal_articles_select_quetions entity = new usp_portal_articles_select_quetions();
                entity.Status = status;
                return BO_Actions<usp_portal_articles_select_quetions>.ExecuteAndReturnDataTable(entity);
            } catch(Exception ex) {
                throw ex;
            }
        }
    }
}

